import json
from typing import Dict, Any


class CarExtras:
    """
    选装件实体类
    用于表示车辆的选装配置项
    """
    
    def __init__(self, optional_name: str, optional_price: str):
        """
        初始化选装件对象
        
        Args:
            optional_name (str): 选装件名称
            optional_price (str): 选装件价格字符串
        """
        self.optional_name = optional_name
        self.optional_price = optional_price
    
    def toJSONString(self) -> str:
        """
        输出符合output.json格式的JSON字符串
        
        Returns:
            str: JSON格式的字符串
        """
        data = {
            "Extra_name": self.optional_name,
            "price": self.optional_price
        }
        return json.dumps(data, ensure_ascii=False, indent=4)
    
    def to_dict(self) -> Dict[str, Any]:
        """
        转换为字典格式
        
        Returns:
            Dict[str, Any]: 字典格式的数据
        """
        return {
            "Extra_name": self.optional_name,
            "price": self.optional_price
        }
    
    def __str__(self) -> str:
        """字符串表示"""
        return f"CarExtras(name={self.optional_name}, price={self.optional_price})"
    
    def __repr__(self) -> str:
        """详细字符串表示"""
        return f"CarExtras(optional_name='{self.optional_name}', optional_price='{self.optional_price}')"
